package org.jiangy.usercenter.entity;

import jakarta.persistence.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * 外部客户
 * <p>创建时间: 2024/8/13 </p>
 *
 * @author <a href="mailto:jiangliu0316@outlook.com" rel="nofollow">蒋勇</a>
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
@Entity
public class Customer extends User {

    private String realName;

    /**
     * 是否是收货商
     */
    @SuppressWarnings("unused")
    public boolean isReseller() {
        return resellerInfo != null;
    }

    /**
     * 是否是供应商
     */
    @SuppressWarnings("unused")
    public boolean isSupplier() {
        return supplierInfo != null;
    }
    
    @OneToOne(mappedBy = "customer", optional = false)
    private Supplier supplierInfo;

    @OneToOne(mappedBy = "customer", optional = false)
    private Reseller resellerInfo;

    @Column(columnDefinition = "decimal(10,2) DEFAULT 0")
    private BigDecimal lockedDeposit;
}
